package com.platform.usercenter.service.impl;


import com.platform.common.core.utils.DateUtils;
import com.platform.usercenter.domain.ContactRelation;
import com.platform.usercenter.mapper.ContactRelationMapper;
import com.platform.usercenter.service.IContactRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;


/**
 * 联系人关系Service业务层处理
 *
 * @author platform
 * @date 2023-10-08
 */
@Service
public class ContactRelationServiceImpl implements IContactRelationService
{
    @Resource
    private ContactRelationMapper contactRelationMapper;

    /**
     * 查询联系人关系
     *
     * @param id 联系人关系主键
     * @return 联系人关系
     */
    @Override
    public ContactRelation selectContactRelationById( Long id)
    {
        return contactRelationMapper.selectContactRelationById(id);
    }

    /**
     * 查询联系人关系列表
     *
     * @param contactRelation 联系人关系
     * @return 联系人关系
     */
    @Override
    public List< ContactRelation > selectContactRelationList( ContactRelation contactRelation)
    {
        return contactRelationMapper.selectContactRelationList(contactRelation);
    }

    /**
     * 新增联系人关系
     *
     * @param contactRelation 联系人关系
     * @return 结果
     */
    @Override
    public int insertContactRelation( ContactRelation contactRelation)
    {
        contactRelation.setCreateTime(DateUtils.getNowDate());
        return contactRelationMapper.insertContactRelation(contactRelation);
    }

    /**
     * 修改联系人关系
     *
     * @param contactRelation 联系人关系
     * @return 结果
     */
    @Override
    public int updateContactRelation( ContactRelation contactRelation)
    {
        contactRelation.setUpdateTime(DateUtils.getNowDate());
        return contactRelationMapper.updateContactRelation(contactRelation);
    }

    /**
     * 批量删除联系人关系
     *
     * @param ids 需要删除的联系人关系主键
     * @return 结果
     */
    @Override
    public int deleteContactRelationByIds(Long[] ids)
    {
        return contactRelationMapper.deleteContactRelationByIds(ids);
    }

    /**
     * 删除联系人关系信息
     *
     * @param id 联系人关系主键
     * @return 结果
     */
    @Override
    public int deleteContactRelationById(Long id)
    {
        return contactRelationMapper.deleteContactRelationById(id);
    }

    /**
     * 查询符合条件的常用联系人
     *
     * @param userId
     * @return
     */
    @Override
    public ArrayList< String > selectContactRelationByUserId( Long userId ) {
        return contactRelationMapper.selectContactRelationByUserId(userId);
    }
}
